package com.yeshine.opendata.service.impl;

import com.yeshine.opendata.core.ServiceBase;
import com.yeshine.opendata.dao.IDictionaryDao;
import com.yeshine.opendata.entity.SysDictionary;
import com.yeshine.opendata.service.IDictionaryService;
import com.yeshine.opendata.utils.PageResult;
import com.yeshine.opendata.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by taohj on 2014/8/13.
 */
@Service
public class DictionaryServiceImpl extends ServiceBase<SysDictionary> implements IDictionaryService {

    @Autowired
    private IDictionaryDao dao;

    @Override
    public Result<SysDictionary> create(SysDictionary sysDictionary) {
        return new Result<SysDictionary>(dao.insert(sysDictionary)>0);
    }

    @Override
    public Result<SysDictionary> remove(SysDictionary sysDictionary) {
        return new Result<SysDictionary>(dao.delete(sysDictionary)>0);
    }

    @Override
    public Result<SysDictionary> modify(SysDictionary sysDictionary) {
        return new Result<SysDictionary>(dao.update(sysDictionary)>0);
    }

    @Override
    public Result<SysDictionary> getById(Integer id) {
        return new Result<SysDictionary>(dao.selectById(id));
    }

    @Override
    public Result<SysDictionary> getList(SysDictionary sysDictionary) {
        return new Result<SysDictionary>(dao.selectList(sysDictionary));
    }

    @Override
    public Result<SysDictionary> getByPage(PageResult<SysDictionary> pageResult) {
        pageResult.setRows(dao.selectbyPage(pageResult));
        return new Result<SysDictionary>(pageResult);
    }
}
